var SqlHelper = require('./sqlHelper.js')

class Dal {
    constructor(key, data, table) {
        // this.userData = userData
        // this.sqlHelper = new SqlHelper();
        this.data = data;
        this.primeryKey = key;
        this.sqlHelper = new SqlHelper(table);;
    }

    add() {
        return this.sqlHelper.asyncInsert(this.data);
    }

    delete() {
        return this.sqlHelper.asyncDelete(this.primeryKey);
    }

    update() {
        return this.sqlHelper.asyncUpdate(this.primeryKey, this.data)
    }

    select() {
        return this.sqlHelper.asyncSelect(this.primeryKey)
    }

    fullSelect() {
        return this.sqlHelper.asyncSelect(this.data)
    }

    selectAll(where, offset, limit, orderby, sort) {
        return this.sqlHelper.asyncSelect(where, offset, limit, orderby, sort)
    }

    likeSelectAll(where, offset, limit, orderby, sort) {
        return this.sqlHelper.asyncLikeSelect(where, offset, limit, orderby, sort)
    }

    comments() {
        return this.sqlHelper.asyncComments();
    }

    likeCount(where) {
        return this.sqlHelper.asyncLikeCount(where);
    }

    count(where) {
        return this.sqlHelper.asyncCount(where);
    }
}
module.exports = Dal;